#include <cstdio>

int gcd(int x, int y) {
	if(0 == y) {
		return x;
	} else {
		return gcd(y, x%y);
	}
}

int main()
{
	int t;
	int x, y;

	scanf("%d", &t);
	while(t--) {
		scanf("%d%d", &x, &y);
		printf("%d\n", gcd(x, y));
	}

	return 0;
}